package com.bluedot.bank.action;

//import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.bluedot.bank.dao.account.Account;
import com.bluedot.bank.dao.customer.Customer;
import com.bluedot.bank.dao.customer.CustomerDao;
import com.bluedot.bank.dao.customer.CustomerDaoImpl;
import com.opensymphony.xwork2.ActionSupport;
//import com.sun.tools.jdi.LinkedHashMap;

public class FindCustomerByIdAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Customer customer;
	private String id;
	/*private List<AcoountType> accountTypes=new ArrayList<AcoountType>();
	{
		accountTypes.add(new AcoountType(1,"金融卡"));
		accountTypes.add(new AcoountType(2,"储蓄卡"));
		accountTypes.add(new AcoountType(3,"信用卡"));
	}*/
	private Map<String, List<String>> types=new LinkedHashMap<String, List<String>>();
	{
		types.put("金融卡", Arrays.asList(new String[] {"hi金融卡"}));
		types.put("储蓄卡", Arrays.asList(new String[] {"hi储蓄卡"}));
		types.put("信用卡", Arrays.asList(new String[] {"hi信用卡"}));
	}
	/**
	 * @return the customer
	 */
	public Customer getCustomer() {
		return customer;
	}
	/**
	 * @param customer the customer to set
	 */
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	@Override
	public String execute() throws Exception {
		CustomerDao customerDao=new CustomerDaoImpl();
		this.customer=customerDao.findById(id);
		Set<Account> set=customer.getAccounts();
		if(set!=null){
			Iterator<Account> iterator=set.iterator();
			while(iterator.hasNext()){
				Account account=iterator.next();
				/*for(int i=0;i<accountTypes.size();i++){
					if(account.getType().equals(accountTypes.get(i).getName())){
						accountTypes.remove(i);
					}
				}*/
				types.remove(account.getType());
			}
		}
		return SUCCESS;
	}
	/**
	 * @return the accountTypes
	 */
	/*public List<AcoountType> getAccountTypes() {
		return accountTypes;
	}
	*//**
	 * @param accountTypes the accountTypes to set
	 *//*
	public void setAccountTypes(List<AcoountType> accountTypes) {
		this.accountTypes = accountTypes;
	}*/
	/**
	 * @return the types
	 */
	public Map<String, List<String>> getTypes() {
		return types;
	}
	/**
	 * @param types the types to set
	 */
	public void setTypes(Map<String, List<String>> types) {
		this.types = types;
	}

}
/*class AcoountType{
	private int key;
	private String name;
	public AcoountType(int key,String name){
		this.key=key;
		this.name=name;
	}
	*//**
	 * @return the key
	 *//*
	public int getKey() {
		return key;
	}
	*//**
	 * @param key the key to set
	 *//*
	public void setKey(int key) {
		this.key = key;
	}
	*//**
	 * @return the name
	 *//*
	public String getName() {
		return name;
	}
	*//**
	 * @param name the name to set
	 *//*
	public void setName(String name) {
		this.name = name;
	}
}*/
